import 'package:wan_android_flutter/common/network/model/categorys_model.dart';
import 'package:wan_android_flutter/common/network/model/hot_web_model.dart';
import 'package:wan_android_flutter/common/network/model/hot_word_model.dart';
import 'package:wan_android_flutter/common/network/model/login_model.dart';
import 'package:wan_android_flutter/common/network/model/tutorials_model.dart';

import 'model/banner_model.dart';
import 'model/favorites_model.dart';
import 'model/knowledges_model.dart';
import 'model/search_result_model.dart';
import 'model/single_knowledges_model.dart';

class JsonParse {
  static M? fromJsonMap<M>(Map<String, dynamic> json) {
    if (M == BannerModel) {
      return BannerModel.fromJson(json) as M;
    }
    if (M == CategorysModel) {
      return CategorysModel.fromJson(json) as M;
    }
    if (M == KnowledgesModel) {
      return KnowledgesModel.fromJson(json) as M;
    }
    if (M == SingleKnowledgesModel) {
      return SingleKnowledgesModel.fromJson(json) as M;
    }
    if (M == HotWebModel) {
      return HotWebModel.fromJson(json) as M;
    }
    if (M == HotWordModel) {
      return HotWordModel.fromJson(json) as M;
    }
    if (M == SearchResultModel) {
      return SearchResultModel.fromJson(json) as M;
    }
    if (M == TutorialsModel) {
      return TutorialsModel.fromJson(json) as M;
    }
    if (M == LoginModel) {
      return LoginModel.fromJson(json) as M;
    }
    if (M == FavoritesModel) {
      return FavoritesModel.fromJson(json) as M;
    }
    return json as M;
  }
}
